package com.bawei.lib_mvi.base

import androidx.lifecycle.ViewModel
import com.bawei.lib_mvi.IIntent
import com.bawei.lib_mvi.IViewModel
import kotlinx.coroutines.channels.Channel

abstract class BaseViewModel<I: IIntent>: ViewModel(), IViewModel<I> {

    protected val _intents = Channel<I> { Channel.UNLIMITED }
    override val intents: Channel<I>
        get() = _intents

    init {
        handleIntent() //处理意图：根据不同意图请求不同数据
    }
    abstract fun handleIntent()
}